<template>
	<view class="login" :style="{marginTop:height.statusBarHeight+'px'}" ref="top">
		<div class="login_top">
			<u-icon name="arrow-left" color="#000000" size="24" @click="goData"></u-icon>
			<p class="top_p">momo笔记</p>
			<div class="right_bot"></div>
		</div>
		<!-- logo -->
		<div class="logo" v-show="!flag">
			<div class="logoImg">
				<div class="imgnos">图</div>
			</div>
			<p>momo笔记</p>
			<button class="btn_one" @click="open">微信授权一键登录</button>
			<button class="btn_two" @click="flag=true">手机号登录/注册</button>
		</div>



		<!-- 获取手机验证号码 -->
		<div class="logo" v-show="flag">
			<p class="lo_p">您好，</p>
			<p class="lo_p">欢迎来到momo笔记！</p>


			<view class="u-demo-block">

				<view class="u-demo-block__content" style="margin-top: 40px;">
					<!-- 注意：由于兼容性差异，如果需要使用前后插槽，nvue下需使用u--input，非nvue下需使用u-input -->
					<!-- #ifndef APP-NVUE -->
					<up-input border="bottom" placeholder="请输入您的手机号" :value="phone">
					<!-- #endif -->
						<!-- #ifdef APP-NVUE -->
						<up-input placeholder="前置插槽">
						<!-- #endif -->
							<template #prefix>
								<up-text prefixIcon="plus"  iconStyle="font-size: 10px" :suffixIcon="icon_phone"  :text="phone_nos" margin="10rpx 10rpx 0 0" type="tips" @click="show_p_list"></up-text>
								<div class="con_list" v-show="flag_phone">
									
								<div v-for="item in phone_list" @click="upd_p_list(item)" class="con_list_item">
									{{item}}
								</div>
								</div>
							</template>
						<!-- #ifndef APP-NVUE -->
						</up-input>
						<!-- #endif -->
						<!-- #ifdef APP-NVUE -->
						</u--input>
						<!-- #endif -->
				</view>
				<view class="u-demo-block__content" style="margin-top: 40px;">
					<!-- 注意：由于兼容性差异，如果需要使用前后插槽，nvue下需使用u--input，非nvue下需使用u-input -->
					<!-- #ifndef APP-NVUE -->
					<up-input border="bottom" placeholder="请输入验证码" :value="code">
					<!-- #endif -->
						<!-- #ifdef APP-NVUE -->
						<up-input border="bottom" placeholder="后置插槽">
						<!-- #endif -->
							<template #suffix>
								<up-code ref="uCodeRef" @change="codeChange" seconds="20" changeText="获取验证码"></up-code>
								<span class="inp_span" @tap="getCode">获取验证码</span>

							</template>
						<!-- #ifndef APP-NVUE -->
						</up-input>
						<!-- #endif -->
					<!-- #ifdef APP-NVUE -->
					</up-input>
					<!-- #endif -->
				</view>
			</view>
			<button class="btn_one1" @click="goHomeOne">登&nbsp;&nbsp;&nbsp;&nbsp;录</button>
		</div>
		<div class="null"></div>

		<div class="botnos">登陆代表同意<span class="span">《用户协议》</span>和<span class="span">《隐私协议》</span></div>
		<!-- <div class=""></div> -->
		<!-- 抽屉 -->
		<u-popup :show="show" :round="20" mode="bottom" @close="close" @open="open" @closeOnClickOverlay='true'>
			<view class="alert">
				<div class="alert_top">
					<img class="alert_img" src="/static/momo.png" alt="" />
					<p class="ps">momo笔记 申请</p>
				</div>
				<h3 class="h31">使用你的手机号码</h3>
				<h3 class="h3"><span>18682000000</span> <span class="h3_span">微信绑定手机号</span></h3>
				<h3 class="h3 hc">使用其他手机号</h3>
				<div class="alert_btn">
					<button class="btn" @click="close()" style="border: 0;">拒绝</button>
					<button class="btn btn_c" @click="goHome">允许</button>
				</div>
			</view>
		</u-popup>
	</view>
</template>

<script setup>
	import {
		onMounted,
		ref,
		watch
	} from 'vue';
	// import { onLoad} from "@dcloudio/uni-app"
	// onLoad((e)=>{
	// 	// console.log(e)
	// 	console.log('我是onload')
	// })

	//状态栏高度
	const height = ref(0)
	const rop = ref(null)
	const flag = ref(false)
	// 抽屉开关
	const show = ref(false)
	const open = () => {

		show.value = true

		console.log('open');
	}
	const close = () => {
		show.value = false
		console.log('close');
	}
	onMounted(async () => {
		height.value = await uni.getSystemInfoAsync()
		console.log(height.value.statusBarHeight);
	})
	
	//icon图标库
	const icon_phone = ref('arrow-down-fill')
	const phone_nos=ref('86')


	const phone_list = ref(['86','1','63','78','24'])

	const tips = ref('');
	const value = ref('');
	const uCodeRef = ref(null);
	
	//用来进行控制手机号的下拉框的
	const flag_phone = ref(false)
	//手机号
	const phone = ref('')
	
	//验证码
	const code = ref('')
	
	
	// //获取手机号
	// const getPhone = (event)=>{
	// 	console.log(event)
	// }
	
	// //获取验证码
	// const getCode11 = (event)=>{
	// 	console.log(event)
	// }
	
	//获取验证码

	watch(value, (newValue, oldValue) => {
		// console.log('v-model', newValue);
	});
	const goData = () => {
		flag.value = false
	}

	const codeChange = (text) => {
		tips.value = text;
	};
	const upd_p_list = (val)=>{
		phone_nos.value = val
		flag_phone.value = false
		icon_phone.value = 'arrow-down-fill'
	}

	const getCode = () => {
		if (uCodeRef.canGetCode) {
			// 模拟向后端请求验证码
			uni.showLoading({
				title: '正在获取验证码',
			});
			setTimeout(() => {
				uni.hideLoading();
				// 这里此提示会被start()方法中的提示覆盖
				uni.$u.toast('验证码已发送');
				// 通知验证码组件内部开始倒计时
				uCodeRef.start();
			}, 2000);
		} else {
			uni.$u.toast('倒计时结束后再发送');
		}
	};

	const change = (e) => {
		console.log('change', e);
	};



//验证码正则
	const goHome = () => {
		uni.switchTab({
			url: "/pages/index/index"
		})
	}
	
	//手机号登录去往首页
	const goHomeOne = ()=>{
		console.log('goHomeOne')
		console.log(phone,'手机号')
		console.log(code,'验证码')
		uni.switchTab({
			url: "/pages/index/index"
		})
		
	}
	const show_p_list = ()=>{
		icon_phone.value = 'arrow-up-fill'
		flag_phone.value = true
	}
</script>

<style scoped lang="scss">
	$uni-color-font: #889aff;

	.login_top {
		height: 40px;
		display: flex;
		align-items: center;
		font-family: '微软雅黑';
		padding: 0 10rpx;
		justify-content: space-evenly;

		.right_bot {
			width: 40rpx;
		}

		.top_p {
			flex: 1;
			text-align: center;
			font-weight: bold;
		}
	}

	.null {
		width: 100%;
		height: 300rpx;
	}

	.botnos {
		text-align: center;
		font-size: 25rpx;

		.span {
			color: $uni-color-font
		}
	}

	.logo {
		text-align: center;
		padding: 180rpx 40rpx 0rpx;
		// display: flex;
		// flex-direction: column;
		font-family: '微软雅黑';

		.logoImg {
			width: 100%;

			height: 300rpx;
			display: flex;
			justify-content: center;
		}

		.imgnos {
			width: 250rpx;
			height: 250rpx;
			background-color: #5997f8;
			border-radius: 50%;
			font-size: 150rpx;
			color: white;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.btn_one {
			margin-top: 60rpx;
			border-radius: 46rpx;
			color: white;
			border: 0px solid white;
			background-color: #5997f8;
		}

		.btn_one1 {
			margin-top: 60rpx;
			border-radius: 46rpx;
			color: white;
			border: 0px solid white;
			background-color: $uni-color-font;
		}

		.btn_two {
			margin-top: 40rpx;
			border-radius: 46rpx;
			color: rgb(60, 156, 255);
			border: 1px solid rgb(60, 156, 255);
			background-color: white;
		}

		.lo_p {
			margin-top: 10rpx;
			text-align: left;
			font-size: 45rpx;
			color: $uni-color-font;
		}

		.inp_span {
			font-size: 30rpx;
			color: $uni-color-font;
		}

		.u-demo-block__content {
			margin-top: 20px;
			position: relative;
		}
		.con_list{
			position: absolute;
			width: 100rpx;
			top: 70rpx;
			left: 0;
			text-align: center;
			background-color: white;
			z-index: 10000;
			.con_list_item{
				height: 80rpx;
				line-height: 80rpx;
				border-bottom: 1rpx solid #eee;
			}
		}
	}

	.alert {
		padding: 0rpx 40rpx;
		// font-family: "宋体";
		font-family: '微软雅黑';

		.alert_top {
			display: flex;
			padding: 30rpx 0px;
			// font-size: 24rpx;
			font-weight: bold;
			align-items: center;

			.alert_img {
				height: 50rpx;
				width: 60rpx;
				border-radius: 50%;
				overflow: hidden;
			}

			.ps {
				padding-left: 5px;
				font-size: 30rpx;
			}
		}

		.h31 {
			height: 40rpx;
			padding: 10px 0px;
			// line-height: 40px;
			font-weight: bold;
			// font-family: "宋体";
			font-family: '微软雅黑';
			font-size: 30rpx;

			.h3_span {
				padding-left: 10px;
				color: #ccc;
				font-size: 22rpx;

			}
		}

		.h3 {
			height: 40rpx;
			padding: 10px 0px;
			// line-height: 40px;
			font-weight: bold;
			// font-family: "宋体";
			font-family: '微软雅黑';
			font-size: 30rpx;
			font-weight: 400;

			.h3_span {
				padding-left: 10px;
				color: #ccc;
				font-size: 22rpx;

			}
		}

		.hc {
			color: #7e8dae;
		}

		.alert_btn {
			display: flex;
			padding: 60rpx 30rpx;
			align-items: center;

			.btn {
				color: #07c160;
				background-color: #f2f2f2;
				// border: 0px;
				// border: 1rpx solid #f2f2f2;
				outline: none;
				height: 80rpx;
				width: 240rpx;
				font-size: 32rpx;
				// display: flex;
				// align-items: center;
				// justify-content: center;
				// padding: 0rpx 40rpx;
			}

			.btn_c {
				background-color: #07c160;
				color: white;
			}
		}
	}
</style>